package com.starview.star.compiler.sources;

import java.util.List;

import com.starview.platform.data.value.ResourceURI;
import com.starview.platform.resource.catalog.Catalog;
import com.starview.star.compiler.util.PrettyPrintDisplay;
import com.starview.star.compiler.util.PrettyPrintable;

@SuppressWarnings("serial")
public class PkgSpec implements PrettyPrintable
{
  private final List<ResourceURI> dependants;
  private final List<ResourceURI> references;
  private final ResourceURI uri;
  private final Catalog catalog;

  public PkgSpec(ResourceURI uri, Catalog catalog, List<ResourceURI> dependants, List<ResourceURI> references)
  {
    this.dependants = dependants;
    this.references = references;
    this.uri = uri;
    this.catalog = catalog;
  }

  public List<ResourceURI> getDeps()
  {
    return dependants;
  }

  public List<ResourceURI> getReferences()
  {
    return references;
  }

  public ResourceURI getUri()
  {
    return uri;
  }

  public Catalog getCatalog()
  {
    return catalog;
  }

  @Override
  public void prettyPrint(PrettyPrintDisplay disp)
  {
    uri.prettyPrint(disp);
    if (!dependants.isEmpty()) {
      disp.append("<-[");
      disp.prettyPrint(dependants, ",");
      disp.append("]");
    }
  }

  @Override
  public String toString()
  {
    return PrettyPrintDisplay.toString(this);
  }

}
